#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 310;

int a[N][N], s[N][N], n, m;
ll ans = 0;
int up[N][N], stk[N], rig[N][N], lft[N][N], top;

int qs(int xl, int yl, int xr, int yr) { return xl > xr || yl > yr ? 0 : s[xr][yr] - s[xl - 1][yr] - s[xr][yl - 1] + s[xl - 1][yl - 1]; }

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	n = in, m = in; rep(i, 1, n) rep(j, 1, m) a[i][j] = in, s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
	rep(i, 1, n) rep(j, 1, m) up[i][j] = i + 1;
	per(x, 300, 1) {
		rep(i, 1, n) {
			top = 0;
			rep(j, 1, m) {
				while(up[i][j] > 1 && a[up[i][j] - 1][j] >= x) up[i][j]--;
				while(top && up[i][j] > up[i][stk[top]])
					rig[i][stk[top]] = j - 1, top--;
				lft[i][j] = a[i][stk[top]] == a[i][j] ? lft[i][stk[top]] : stk[top] + 1;
				stk[++top] = j;
				//chkmax(ans, 1ll * qs(up[i][j], stk[top] + 1, i, j) * x); stk[++top] = j;
			}
			while(top) rig[i][stk[top]] = m, top--;
			rep(j, 1, m) chkmax(ans, 1ll * qs(up[i][j], lft[i][j], i, rig[i][j]) * x);
		}
		/*
		if(x == 3) {
			rep(i, 1, n) rep(j, 1, m) printf("%d%c", up[i][j], " \n"[j == m]);
		}
		*/
	} cout << ans << endl;
	return 0;
}
